using System;
using System.Collections.Generic;
using System.Linq;

namespace LeanUi.ImageBundle
{
    public static class StringExtentions
    {
        public static string CorrectNewLines(this string s)
        {
            return s.Replace(Environment.NewLine, "\n").Replace("\n", Environment.NewLine);
        }

        public static string Join<T>(this IEnumerable<T> entities, Func<T, string> func)
        {
            return Join<T>(entities, func, "\n");
        }

        public static string Join<T>(this IEnumerable<T> entities, Func<T, string> func, string seperator)
        {
            return String.Join(seperator, entities.Select(func).ToArray());
        }

        public static string Join<T>(this IEnumerable<T> entities, string seperator)
        {
            return String.Join(seperator, entities.Select(x=>x.ToString()).ToArray());
        }
    }
}